package com.xhj.ipersistent.parsing;

import com.xhj.ipersistent.mapping.ParameterMapping;

import java.util.*;


/**
 * ParameterMappingTokenHandler
 *
 * @author XJks
 * @description 参数映射令牌处理器，用于处理SQL语句中的#{}占位符
 */
public class ParameterMappingTokenHandler implements TokenHandler {

    private List<ParameterMapping> parameterMappingList = new ArrayList<>();

    public ParameterMappingTokenHandler() {
    }

    public List<ParameterMapping> getParameterMappingList() {
        return parameterMappingList;
    }

    @Override
    public String handleToken(String content) {
        parameterMappingList.add(buildParameterMapping(content));
        return "?";
    }

    private ParameterMapping buildParameterMapping(String content) {
        return new ParameterMapping(content);
    }
}